import 'package:flutter_admin/utils/utils.dart';

class StockMaterialarrival {
  String? id;
  String? purchaseordercode;
  String? linenumber;
  String? area;
  String? materialcode;
  String? materialname;
  String? transmitnumber;
  String? receiptnumber;
  String? suppliercode;
  String? suppliername;
  String? purchaseunit;
  String? arrivalquantity;
  String? deliveredfashion;
  String? arriveddate;
  String? remark;
  String? createUid;
  String? createDate;
  String? writeUid;
  String? writeDate;

  StockMaterialarrival({
    this.id,
    this.purchaseordercode,
    this.linenumber,
    this.area,
    this.materialcode,
    this.materialname,
    this.transmitnumber,
    this.receiptnumber,
    this.suppliercode,
    this.suppliername,
    this.purchaseunit,
    this.arrivalquantity,
    this.deliveredfashion,
    this.arriveddate,
    this.remark,
    this.createUid,
    this.createDate,
    this.writeUid,
    this.writeDate,
  });

  StockMaterialarrival copyWith({
    String? id,
    String? purchaseordercode,
    String? linenumber,
    String? area,
    String? materialcode,
    String? materialname,
    String? transmitnumber,
    String? receiptnumber,
    String? suppliercode,
    String? suppliername,
    String? purchaseunit,
    String? arrivalquantity,
    String? deliveredfashion,
    String? arriveddate,
    String? remark,
    String? createUid,
    String? createDate,
    String? writeUid,
    String? writeDate,
  }) {
    return new StockMaterialarrival(
      id: id ?? this.id,
      purchaseordercode: purchaseordercode ?? this.purchaseordercode,
      linenumber: linenumber ?? this.linenumber,
      area: area ?? this.area,
      materialcode: materialcode ?? this.materialcode,
      materialname: materialname ?? this.materialname,
      transmitnumber: transmitnumber ?? this.transmitnumber,
      receiptnumber: receiptnumber ?? this.receiptnumber,
      suppliercode: suppliercode ?? this.suppliercode,
      suppliername: suppliername ?? this.suppliername,
      purchaseunit: purchaseunit ?? this.purchaseunit,
      arrivalquantity: arrivalquantity ?? this.arrivalquantity,
      deliveredfashion: deliveredfashion ?? this.deliveredfashion,
      arriveddate: arriveddate ?? this.arriveddate,
      remark: remark ?? this.remark,
      createUid: createUid ?? this.createUid,
      createDate: createDate ?? this.createDate,
      writeUid: writeUid ?? this.writeUid,
      writeDate: writeDate ?? this.writeDate,
    );
  }

  @override
  String toString() {
    return '''StockMaterialarrival{
      id: id,
      purchaseordercode: purchaseordercode,
      linenumber: linenumber,
      area: area,
      materialcode: materialcode,
      materialname: materialname,
      transmitnumber: transmitnumber,
      receiptnumber: receiptnumber,
      suppliercode: suppliercode,
      suppliername: suppliername,
      purchaseunit: purchaseunit,
      arrivalquantity: arrivalquantity,
      deliveredfashion: deliveredfashion,
      arriveddate: arriveddate,
      remark: remark,
      createUid: createUid,
      createDate: createDate,
      writeUid: writeUid,
      writeDate: writeDate,
    }''';
  }

  @override
  bool operator ==(Object other) =>
      identical(this, other) ||
      (other is StockMaterialarrival &&
          runtimeType == other.runtimeType &&
          id == other.id &&
          purchaseordercode == other.purchaseordercode &&
          linenumber == other.linenumber &&
          area == other.area &&
          materialcode == other.materialcode &&
          materialname == other.materialname &&
          transmitnumber == other.transmitnumber &&
          receiptnumber == other.receiptnumber &&
          suppliercode == other.suppliercode &&
          suppliername == other.suppliername &&
          purchaseunit == other.purchaseunit &&
          arrivalquantity == other.arrivalquantity &&
          deliveredfashion == other.deliveredfashion &&
          arriveddate == other.arriveddate &&
          remark == other.remark &&
          createUid == other.createUid &&
          createDate == other.createDate &&
          writeUid == other.writeUid &&
          writeDate == other.writeDate);

  factory StockMaterialarrival.fromMap(Map<String, dynamic> map) {
    return new StockMaterialarrival(
      id: map['id'] != false ? map['id'].toString() as String? : "",
      purchaseordercode: map['purchaseordercode'] != false
          ? map['purchaseordercode'].toString() as String?
          : "",
      linenumber: map['linenumber'] != false
          ? map['linenumber'].toString() as String?
          : "",
      area: map['area'] != false ? map['area'].toString() as String? : "",
      materialcode: map['materialcode'] != false
          ? map['materialcode'].toString() as String?
          : "",
      materialname: map['materialname'] != false
          ? map['materialname'].toString() as String?
          : "",
      transmitnumber: map['transmitnumber'] != false
          ? map['transmitnumber'].toString() as String?
          : "",
      receiptnumber: map['receiptnumber'] != false
          ? map['receiptnumber'].toString() as String?
          : "",
      suppliercode: map['suppliercode'] != false
          ? map['suppliercode'].toString() as String?
          : "",
      suppliername: map['suppliername'] != false
          ? map['suppliername'].toString() as String?
          : "",
      purchaseunit: map['purchaseunit'] != false
          ? map['purchaseunit'].toString() as String?
          : "",
      arrivalquantity: map['arrivalquantity'] != false
          ? map['arrivalquantity'].toString() as String?
          : "",
      deliveredfashion: map['deliveredfashion'] != false
          ? map['deliveredfashion'].toString() as String?
          : "",
      arriveddate: map['arriveddate'] != false
          ? map['arriveddate'].toString() as String?
          : "",
      remark: map['remark'] != false ? map['remark'].toString() as String? : "",
      createUid: map['create_uid'] != false
          ? map['create_uid'].toString() as String?
          : "",
      createDate: map['create_date'] != false
          ? map['create_date'].toString() as String?
          : "",
      writeUid: map['write_uid'] != false
          ? map['write_uid'].toString() as String?
          : "",
      writeDate: map['write_date'] != false
          ? map['write_date'].toString() as String?
          : "",
    );
  }

  Map<String, dynamic> toMap() {
    // ignore: unnecessary_cast
    return {
      'id': this.id,
      'purchaseordercode': this.purchaseordercode,
      'linenumber': this.linenumber,
      'area': this.area,
      'materialcode': this.materialcode,
      'materialname': this.materialname,
      'transmitnumber': this.transmitnumber,
      'receiptnumber': this.receiptnumber,
      'suppliercode': this.suppliercode,
      'suppliername': this.suppliername,
      'purchaseunit': this.purchaseunit,
      'arrivalquantity': this.arrivalquantity,
      'deliveredfashion': this.deliveredfashion,
      'arriveddate': this.arriveddate,
      'remark': this.remark,
      'createUid': this.createUid,
      'createDate': this.createDate,
      'writeUid': this.writeUid,
      'writeDate': this.writeDate,
    } as Map<String, dynamic>;
  }

  List toDomainList() {
    List list = [
      if (this.purchaseordercode != null && this.purchaseordercode != '')
        ['purchaseordercode', '=', this.purchaseordercode],
    ] as List;
    // if (list.length == 0) {
    //   list.add(['id', '!=', null]);
    // }
    // ignore: unnecessary_cast
    return list;
  }

  Map<String, dynamic> toOdooMap() {
    // ignore: unnecessary_cast
    return {
      'id': this.id,
      'purchaseordercode': this.purchaseordercode,
      'linenumber': this.linenumber,
      'area': this.area,
      'materialcode': this.materialcode,
      'materialname': this.materialname,
      'transmitnumber': this.transmitnumber,
      'receiptnumber': this.receiptnumber,
      'suppliercode': this.suppliercode,
      'suppliername': this.suppliername,
      'purchaseunit': this.purchaseunit,
      'arrivalquantity': this.arrivalquantity,
      'deliveredfashion': this.deliveredfashion,
      'arriveddate': this.arriveddate,
      'remark': this.remark,
      'create_uid': this.createUid,
      'create_date': this.createDate,
      'write_uid': this.writeUid,
      'write_date': this.writeDate,
    } as Map<String, dynamic>;
  }

//</editor-fold>

}
